﻿Imports System.Collections.Generic

Public Class BCEvento
    Public Shared Function SalvarEvento(ByVal objBEEvento As BE.BEEvento) As String
        Dim objDAEvento As New DA.DAEvento
        Dim objDATelasEvento As New DA.DATelasEvento
        Dim strIdEvento As String
        strIdEvento = objDAEvento.Salvar(objBEEvento)
        For Each objBETelaEvento As BE.BETelaEvento In objBEEvento.TelasEvento
            BC.BCTelaEvento.SalvarTela(strIdEvento, objBETelaEvento)
        Next
        Return strIdEvento
    End Function
    Public Shared Sub DeletarEvento(ByVal strIdEvento As String)
        Dim objDAEvento As New DA.DAEvento
        Dim objBEEvento As BE.BEEvento = objDAEvento.Selecionar(strIdEvento)

        For Each objBEInscrito As BE.BEInscrito In objBEEvento.InscritosEvento
            BC.BCInscrito.Deletar(objBEInscrito.IdInscrito)
        Next

        For Each objBETelasEvento As BE.BETelaEvento In objBEEvento.TelasEvento
            BC.BCTelaEvento.DeletarTela(objBETelasEvento.IdTela)
        Next

        objDAEvento.Deletar(strIdEvento)
    End Sub

    Public Shared Function ListarEvento(ByVal booSomenteAtivos As Boolean) As List(Of BE.BEEvento)
        Dim objDAEvento As New DA.DAEvento
        Dim objDAInscritos As New DA.DAInscritos
        Dim lstBEEvento As List(Of BE.BEEvento) = IIf(booSomenteAtivos, objDAEvento.ListarAtivos(), objDAEvento.ListarInativos())
        For Each objBEEvento As BE.BEEvento In lstBEEvento
            objBEEvento.InscritosEvento = objDAInscritos.Listar(objBEEvento.IdEvento)
        Next
        Return lstBEEvento
    End Function

    Public Shared Function SelecionarEvento(ByVal strIdEvento As String) As BE.BEEvento
        Dim objDAEvento As New DA.DAEvento
        Dim objBEEvento As BE.BEEvento
        objBEEvento = objDAEvento.Selecionar(strIdEvento)
        objBEEvento.InscritosEvento = BCInscrito.ListarInscritos(strIdEvento)
        objBEEvento.TelasEvento = BCTelaEvento.ListarTelas(strIdEvento)
        Return objBEEvento
    End Function

    

End Class
